void main() {
  // firstMethod();
  // getPrint();
  // thirdMethod(1,2);
  printer1(75,s2:"111");




  // printer2(75);
  // printer3(75);
  // var result = mysteryMessage('Billy', 'howdy', 'the ranch');
  // print(result); // Billy said howdy at the ranch


  OperatorClass obj1 = OperatorClass();
  obj1.a = 49;
  OperatorClass obj2 = OperatorClass();
  obj2.a = 50;
  //设计思路不同
  //java是帮你们把操作该重载的全部处理了
  //dart是把操作符重载的操作，放出来了
  print(obj1 > obj2);

}

void firstMethod() {
  print('定义了一个方法');
}


String getPrint() {
  return '带有返回值的方法';
}

int thirdMethod(int x, int y) {
  return x + y; //必填带参函数
}

//=> expr 等同于{ return expr; }
int add(int a, int b) => a + b;


//dart不支持java函数重载
// printer1(num n, {String? s1, String? s2}) {
//   print(n); // 75
//   print(s1); // hello
//   print(s2); // null
// }
// printer1(num n) {
//   print(n); // 75
//
// }


void test(num n,int a){

}

//dart的参数设计，需要有对应的默认值
//dart在对于默认值的设计过程中，因为他强调所有的对应类型全部是object,默认值未null
printer1(num n, {String? s1, String? s2}) {
  print(n); // 75
  print(s1); // hello
  print(s2); // null
}



printer2(num n, {String? s1, String? s2}) {
  print(n); // 75
  print(s1); // null
  print(s2); // null
}

printer3(num n, {String s1 = '这是默认S1', String? s2}) {
  print(n); // 75
  print(s1); // 这是默认S1
  print(s2); // null
}
//Dart 居然不支持方法重载,但是可以根据可选参数进行处理
String mysteryMessage(String who, [String? what, String? where]){
  var message = who;
  if(what != null && where == null){
    message = '$message said $what';
  } else if (where != null){
    message = '$message said $what at $where';
  }
  return message;
}


// C 操作符重载
class OperatorClass{
  int a = 0;
  bool operator > (OperatorClass obj) => a > obj.a;
}
